package com.woniuxy.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.dao.MenuDao;
import com.woniuxy.dao.PermDao;
import com.woniuxy.entity.Menu;
import com.woniuxy.entity.Perm;
import com.woniuxy.entity.PermDto;
import com.woniuxy.service.MenuService;
import com.woniuxy.service.PermService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO(用一句话描述这个类的作用)
 * @Author 18452
 * @Date 2021/4/26 13:11
 */
@Service
public class MenuServiceImpl implements MenuService {
    @Resource
    private MenuDao menuDao;

//    @Override
//    public PageInfo<Perm> select(PermDto permDto) {
//
//        PageHelper.startPage(permDto.getPage(),permDto.getLimit());
//        List<Perm> permList = permDao.select(permDto.getEditForm());
//        PageInfo<Perm> pageInfo = new PageInfo<>(permList);
//        return pageInfo;
//    }

    @Override
    public List<Menu> selectMenu() {
        List<Menu> menuList = menuDao.selectfatherMenu();
        return menuList;
    }

    @Override
    public List<Menu> selectOne(int id) {
        List<Menu> menuList = menuDao.selectOne(id);
        return menuList;
    }

    @Override
    public List<Menu> selectFatherMenu() {
        List<Menu> menuList = menuDao.selectFatherMenu();
        return menuList;
    }

    @Override
    public String update(Menu menu) {
        int row = menuDao.update(menu);
        if(row <= 0){
            return "defeated";
        }
        return "success";
    }

    @Override
    public String insert(Menu menu) {
        int row = menuDao.insert(menu);
        if(row <= 0){
            return "defeated";
        }
        return "success";
    }

    @Override
    public String delete(int id) {
        int row = menuDao.delete(id);
        if(row <= 0){
            return "defeated";
        }
        return "success";
    }

   /* @Override
    public String insert(Perm perm) {
        int row = permDao.insert(perm);
        if(row == 0){
            return "defeated";
        }
        return "success";
    }

    @Override
    public String update(Perm perm) {
        int row = permDao.update(perm);
        if(row == 0){
            return "defeated";
        }
        return "success";
    }

    @Override
    public String delete(int id) {
        int row = permDao.delete(id);
        if(row == 0){
            return "defeated";
        }
        return "success";
    }*/

}
